#pragma once

#include <sys/socket.h>
#include <sys/un.h>

#define IPC_SOCKET   "\0/tmp/upekuxd.ipc-socket"

extern int checkSocketSecurity( int socket );

static const unsigned char IPC_PROMPT_SWIPE_SCANNER = 0xff;

//ipc commands
static const unsigned char IPC_SUCCESS        = 0x00;
static const unsigned char IPC_ERROR          = 0x01;
static const unsigned char IPC_DENIED         = 0x02;
static const unsigned char IPC_DRIVER_MESSAGE = 0x03;

static const unsigned char IPC_TOUCHPAD        = 0x10;
static const unsigned char IPC_TOUCHPAD_STATUS = 0x11;
static const unsigned char IPC_TOUCHPAD_OFF    = 0x12;
static const unsigned char IPC_TOUCHPAD_MOUSE  = 0x13;
static const unsigned char IPC_TOUCHPAD_WHEELS = 0x14;
static const unsigned char IPC_TOUCHPAD_ARROWS = 0x15;

static const unsigned char IPC_USER_AUTH         = 0x20;
static const unsigned char IPC_USER_AUTH_ACTIVE  = 0x21;
static const unsigned char IPC_USER_AUTH_PASSIVE = 0x22;

static const unsigned char IPC_FINGER_LIST   = 0x30;
static const unsigned char IPC_FINGER_DETECT = 0x31;

static const unsigned char IPC_FINGER_ADD        = 0x50;
static const unsigned char IPC_FINGER_ADD_SINGLE = 0x51;
static const unsigned char IPC_FINGER_ADD_BEST   = 0x52;

static const unsigned char IPC_FINGER_VIEW   = 0x61;
static const unsigned char IPC_FINGER_EDIT   = 0x62;
static const unsigned char IPC_FINGER_TEST   = 0x63;
static const unsigned char IPC_FINGER_REMOVE = 0x64;


//field IDs
static const unsigned char IPC_FIELD_USER        = 0x00;
static const unsigned char IPC_FIELD_DESCRIPTION = 0x01;
static const unsigned char IPC_FIELD_THRESHOLD   = 0x02;
static const unsigned char IPC_FIELD_ACTION      = 0x03;


//field names usable to access to db
static const char ipc_field_user[]        = "user";
static const char ipc_field_description[] = "description";
static const char ipc_field_threshold[]   = "threshold";
static const char ipc_field_action[]      = "action" ;

static const struct ipc_field{ 
	const char* name;//used in db request
	const unsigned char id;
	const char type;//t - text, i - integer
} ipcFieldList[] = {
	{ ipc_field_user,        IPC_FIELD_USER,        't' },
	{ ipc_field_description, IPC_FIELD_DESCRIPTION, 't' },
	{ ipc_field_threshold,   IPC_FIELD_THRESHOLD,   'i' },
	{ ipc_field_action,      IPC_FIELD_ACTION,      't' },
	
	{ NULL, 0x00, 0x00 }//list terminator
};

